package com.gxc.aspect;

import com.gxc.utils.NowDate;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.context.annotation.Configuration;

/**
 * 拦截Controller的切面.
 *
 * @author 宫新程
 * @since 2018/12/14 2:28 PM
 */
@Slf4j
@Aspect
@Configuration
public class MyControllerAspect {

  @Pointcut("execution(* com.gxc.controller.AspectController.*(..))")
  public void controllerPointCut() {}

  /** 拦截Controller的通知. */
  @Around("controllerPointCut()")
  public Object around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
    log.info("Controller Aspect Before： {}", NowDate.getNowDate());
    Object proceed = proceedingJoinPoint.proceed();
    log.info("Controller Aspect After： {}", NowDate.getNowDate());
    return proceed;
  }
}
